import Request from '@/service'
import { resultDataType } from '../types'
import { account, loginDataType } from './types'

enum LoginAPI {
  AccountLogin = '/login',
  LoginUserInfo = '/users/',
  UserMenus = '/role/'
}

export function accountLoginRequest(data: account) {
  // 使用interface定义resultData的泛型
  return Request.post<resultDataType<loginDataType>>({
    url: LoginAPI.AccountLogin,
    data
  })
}

export function userInfoRequest(id: number) {
  return Request.get<resultDataType>({
    url: LoginAPI.LoginUserInfo + id,
    showLoading: false
  })
}

export function userMenusRequest(id: number) {
  return Request.get<resultDataType>({
    url: LoginAPI.UserMenus + `${id}/menu`,
    showLoading: false
  })
}
